const _function = require("../../utils/functionData.js")
Page({
  data: {
    isRefreshing: false,
    isLoading: false,
    hasMore: true,
    page: 1,
    lectureList: [
    //   {
    //   id: 1,
    //   name: "人工智能前沿技术解析",
    //   startTime: "2023-10-10 14:00",
    //   participants: 156
    // }
  ]
  },
  onLoad(options) {
    this.getLectureList()
  },
  getLectureList() {
    const prams = {
      studentId: getApp().globalData.userInfo.userId
    }
    _function.getLectureList(prams, this.getLectureListBack, this)
  },
  getLectureListBack(res) {
    let dataAll = res.data
    if (dataAll.code == 200) {
      this.setData({
        lectureList: dataAll.rows
      })

    }
  },
  onPullDownRefresh() {
    this.setData({ isRefreshing: true });
    setTimeout(() => {
      this.setData({ 
        lectureList: [...newData],
        isRefreshing: false,
        page: 1
      });
      wx.stopPullDownRefresh();
    }, 1500);
  },

  loadMore() {
    if (!this.data.hasMore || this.data.isLoading) return;
    
    this.setData({ isLoading: true });
    setTimeout(() => {
      this.setData({
        lectureList: [...this.data.lectureList, ...newData],
        page: this.data.page + 1,
        isLoading: false,
        hasMore: this.data.page < 3
      });
    }, 1000);
  }
});